<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script src="./promise.js"></script>
    <script>
        console.log(1)
        let x = new myPromise((resolve, reject) => {
            console.log(2)
            setTimeout(() => {
                resolve('接收')
                reject("拒绝")
                console.log(3)
            });
        }).then(
            res => {
                console.log(res)
                return new myPromise((res,rej) => {
                    setTimeout(() => {
                        res("1秒")
                    }, 1000);
                    setTimeout(() => {
                        rej("2秒")
                    }, 2000);
                })
            },
            rej => {
                console.log(rej)
            }
        ).then(
            res => {
                console.log(res)
                return new myPromise((res) => res(">?"))
            }
        ).then(
            res => {
                console.log(res)
            }
        )
        console.log(4)
        console.log(x)
    </script>
</body>

</html>